using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using THSERP.BaseProvider;
using THSERP.BusinessEntities;
using THSLib;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Nodes;
namespace THSERP.Modules.Location.UI
{
	/// <summary>
	/// Summary description for DMLC100
	/// </summary>
	public partial class DMLC100 : THSERPScreen
	{

		public DMLC100()
		{
			//
			// Required designer variable
			//
			InitializeComponent();
		}

        private void fld_btnAddLocationToTreeList_Click(object sender, EventArgs e)
        {
            ((Modules.Location.LocationModule)this.Module).AddLocationToTreeList();
        }

        private void fld_btnChangeLocationToTreeList_Click(object sender, EventArgs e)
        {
            ((Modules.Location.LocationModule)this.Module).ChangeLocationToTreeList();
        }

        private void fld_btnRemoveLocationFromTreeList_Click(object sender, EventArgs e)
        {
            ((Modules.Location.LocationModule)this.Module).RemoveLocationFromTreeList();
        }

       

        #region Do drag/drop
        /// <summary>
        /// Do drag/drop tree list
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>Hieu.nguyen_04/05/2010</remarks>

       // private void fld_trlGELocations_DragOver(object sender, DragEventArgs e)
       // {
       //     TreeListHitInfo hi = fld_trlGELocations.CalcHitInfo(fld_trlGELocations.PointToClient(new Point(e.X, e.Y)));
       //     TreeListNode node = GetDragNode(e.Data);
       //     if (node == null)
       //     {
       //         if (hi.HitInfoType == HitInfoType.Empty || hi.Node != null)
       //             e.Effect = DragDropEffects.Move;
       //         else
       //             e.Effect = DragDropEffects.None;
       //     }
       // }

       // private TreeListHitInfo downHitInfo;

       //private TreeListNode GetDragNode(IDataObject data)
       // {
       //     return data.GetData(typeof(TreeListNode)) as TreeListNode;
       // }

       
       

       // private void fld_trlGELocations_MouseDown(object sender, MouseEventArgs e)
       // {
       //     downHitInfo = null;
       //     TreeListHitInfo hitInfo = fld_trlGELocations.CalcHitInfo(new Point(e.X, e.Y));
       //     if (Control.ModifierKeys != Keys.None) return;
       //     if (e.Button == MouseButtons.Left)
       //         downHitInfo = hitInfo;
       // }

       // private void fld_trlGELocations_MouseMove(object sender, MouseEventArgs e)
       // {
       //     if (e.Button == MouseButtons.Left && downHitInfo != null)
       //     {
       //         Size dragSize = SystemInformation.DragSize;
       //         Rectangle dragRect = new Rectangle(new Point(downHitInfo.MousePoint.X - dragSize.Width / 2,
       //             downHitInfo.MousePoint.Y - dragSize.Height / 2), dragSize);

       //         if (!dragRect.Contains(new Point(e.X, e.Y)))
       //         {
       //             fld_trlGELocations.DoDragDrop(downHitInfo, DragDropEffects.All);
       //             downHitInfo = null;
       //         }
       //     }
       // }

       // private void fld_trlGELocations_DragDrop(object sender, DragEventArgs e)
       // {
       //     TreeListHitInfo hitInfo = fld_trlGELocations.CalcHitInfo(fld_trlGELocations.PointToClient(new Point(e.X, e.Y)));
       //     TreeListNode targetNode = hitInfo.Node;
       //     TreeListNode sourceNode = downHitInfo.Node;
       //     if (targetNode != null)
       //     {
       //         if (targetNode.Level == 1 && sourceNode.Level == 2 && targetNode.ParentNode != sourceNode.ParentNode)
       //         {
       //             GELocationsController objGELocationsController = new GELocationsController();
       //             GELocationsInfo objGELocationsTargetInfo = (GELocationsInfo)objGELocationsController.GetObjectByID((int)targetNode.Tag);
       //             GELocationsInfo objGELocationsSourceInfo = (GELocationsInfo)objGELocationsController.GetObjectByID((int)sourceNode.Tag);

       //             //Update
       //             objGELocationsSourceInfo.GELocationParentID = objGELocationsTargetInfo.GELocationID;
       //             objGELocationsController.UpdateObject(objGELocationsSourceInfo);
       //             //((UserManagementModule)Module).InitializeTreeList(fld_trlstUserGroup);
       //             //((UserManagementModule)Module).RefreshTreeList(fld_trlstUserGroup, targetNode);
       //         }

       //         else
       //             return;
       //     }
       // }
        #endregion
    }
}
